<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>{:config('webconfig.title');}</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
    <meta name="description" content="{:config('webconfig.description');}">
    <meta name="keywords" content="{:config('webconfig.keywords');}">
    <meta name="author" content="runoob">
    <link rel="stylesheet" href="__STATIC_URL__/static/bootstrap/3.3.7/css/bootstrap.min.css">
    <link rel="stylesheet" type="text/css" href="__STATIC_URL__/static/css/index.css"/>
    <link rel="stylesheet" href="__STATIC_URL__/static/css/addmchat.css"/>
    <link rel="stylesheet" type="text/css" href="__STATIC_URL__/static/css/bootstrap-datetimepicker.css"/>
    <link rel="stylesheet" type="text/css" href="__STATIC_URL__/static/css/Statistics.css"/>
    <link rel="stylesheet" type="text/css" href="__STATIC_URL__/static/member/css/core.css"/>
    <link rel="stylesheet" type="text/css" href="__STATIC_URL__/static/css/setlay.css"/>
    <link rel="stylesheet" type="text/css" href="__STATIC_URL__/static/bootstrap-table/bootstrap-table.css"/>
    <script src="__STATIC_URL__/static/jquery/2.2.1/jquery.min.js"></script>
    <script src="__STATIC_URL__/static/bootstrap/3.3.7/js/bootstrap.min.js"></script>
    <script src="__STATIC_URL__/static/js/bootstrap-datetimepicker.js" type="text/javascript" charset="utf-8"></script>
    <script src="__STATIC_URL__/static/js/commen.js" type="text/javascript" charset="utf-8"></script>
    <script src="__STATIC_URL__/static/layer/layer.js"></script>
    <style>

    </style>
</head>
<body>
{include file='public/header'/}
<section id="content">
    <!------------------导航-------------------------->
    {include file='public/left'/}
    <!--------------------------主要内容区域------------------------------------->
    <div class="content">
        <div class="page-heading mgl15 mgr15">
            <ol class="breadcrumb">
                <li>当前位置是&nbsp;:</li>
                <li>交易中心</li>
                <li class="active" style="color: #02b87f;"> 交易明细</li>
            </ol>
        </div>

        <div class="panel panel-search panel-default mgl15 mgr15">
            <div class="panel-heading">
                <h3 class="panel-title">
                    筛选分类
                </h3>
            </div>
            <div class="panel-body">
                <form action="" method="get" class="form-horizontal table-search form-search" role="form" id="machform">
                    <div class="col-sm-6 col-md-6 col-lg-4 ">
                        <div class="form-group">
                            <label class="col-sm-3 control-label">门店：</label>
                            <div class="col-sm-9">
                                <input type="hidden" name="type" id="type" value="search">

                                <input type="hidden" name="mchid" id="mach" value="">
                                <input class="form-control" id="mac" style=" display: inline-block;" value="全部门店"
                                       data-target="#myModal3" data-toggle="modal"/>

                            </div>
                        </div>
                    </div>
                    <div class="col-sm-6 col-md-6 col-lg-4 ">
                        <div class="form-group">
                            <label class="col-sm-3 control-label">交易方式：</label>
                            <div class="col-sm-9">
                                <select name="pay_fs" class="form-control" id="pay_fs">
                                    <option value="">请选择交易方式</option>
                                    <option value="0">微信支付</option>
                                    <option value="1">支付宝支付</option>
                                    <option value="2">微信刷卡支付</option>
                                    <option value="3">支付宝刷卡支付</option>
                                    <option value="8">会员卡支付</option>
                                    <option value="4">现金支付</option>
                                </select>
                            </div>
                        </div>
                    </div>

                    <div class="col-sm-6 col-md-6 col-lg-4">
                        <div class="form-group">
                            <label class="col-sm-3 control-label">订单号：</label>
                            <div class="col-sm-9">
                                <input type="text" name="orderid" id="orderid" class="form-control" placeholder="请输入订单号"
                                       value="">
                            </div>
                        </div>
                    </div>
                    <!--<div class="col-sm-6 col-md-6 col-lg-4">-->
                    <!--<div class="form-group">-->
                    <!--<label class="col-sm-3 control-label">款台：</label>-->
                    <!--<div class="col-sm-9">-->
                    <!--<input type="text" name="orderid" class="form-control" placeholder="请输入款台" value="">-->
                    <!--</div>-->
                    <!--</div>-->
                    <!--</div>-->
                    <!--<div class="col-sm-6 col-md-6 col-lg-4">-->
                    <!--<div class="form-group">-->
                    <!--<label class="col-sm-3 control-label">收银员：</label>-->
                    <!--<div class="col-sm-9">-->
                    <!--<input type="text" name="orderid" class="form-control" placeholder="请输入收银员" value="">-->
                    <!--</div>-->
                    <!--</div>-->
                    <!--</div>-->
                    <!--<div class="col-sm-6 col-md-6 col-lg-4">-->
                    <!--<div class="form-group">-->
                    <!--<label class="col-sm-3 control-label">交易来源：</label>-->
                    <!--<div class="col-sm-9">-->
                    <!--<select name="pay_statu" class="form-control">-->
                    <!--<option value="">请选择交易来源</option>-->
                    <!--<option value="0">自助</option>-->
                    <!--<option value="1">APP</option>-->
                    <!--<option value="2">小程序</option>-->
                    <!--<option value="8">客户端</option>-->
                    <!--<option value="8">收银员</option>-->

                    <!--</select>                            </div>-->
                    <!--</div>-->
                    <!--</div>-->
                    <div class="col-sm-6 col-md-6 col-lg-4">
                        <div class="form-group">
                            <label class="col-sm-3 control-label">交易状态：</label>
                            <div class="col-sm-9">
                                <select name="pay_statu" class="form-control" id="pay_statu">
                                    <option value="">请选择交易状态</option>
                                    <option value="0">未支付</option>
                                    <option value="1">已支付</option>
                                    <option value="2">有退款</option>
                                    <option value="8">订单已关闭</option>
                                </select>
                            </div>
                        </div>
                    </div>

                    <div class="col-sm-6 col-md-6 col-lg-4">
                        <div class="form-group">
                            <label class="col-sm-3 control-label">交易金额：</label>
                            <div class="col-sm-9">
                                <div class="input-group">
                                    <input name="startprice" type="text" id="form-pic" value=""
                                           oninput="value = value.replace(/[^\d.]/g, '')" placeholder="最低金额"
                                           class="form-control">
                                    <div class="input-group-addon ">至</div>
                                    <input name="endprice" type="text" value=""
                                           oninput="value = value.replace(/[^\d.]/g, '')" class="form-control "
                                           id="form-pic1" placeholder="最高金额">
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="col-sm-8 col-md-8 col-lg-5">
                        <div class="form-group">
                            <label class="col-sm-2 control-label">交易时间：</label>
                            <div class="col-sm-9">


                                <input name="search_date" type="text" value=""
                                       readonly="readonly" id="search_date" class="form-control"
                                       placeholder="请选择" style="width: 297px">

                            </div>
                        </div>
                    </div>

                </form>
            </div>

            <div class="panel-footer">
                <a href="javascript:;" class="btn btn-primary" onclick="searchforms()" type="button">查找</a>
                <a href="javascript:;" class="btn btn-default" onclick="clearform()">清空</a>
            </div>
        </div>


        <div class="panel mgl15 mgr15">
            <div class="panel-heading addCharts" style="background:#ededed;">交易明细


                <a href="javascript:;" onclick="load();" class="btn btn-info"
                   style="float: right;  margin-top: -7px;">点击下载</a>

            </div>
            <div class="panel-body">
                <table class="table table-bordered table-striped" id="tablelist">

                </table>
            </div>
        </div>
        {include file='public/footer'/}
    </div>
</section>
<!-- Modal -->
<div class="modal fade" id="myModal3" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
    <div class="modal-dialog" role="document" style="    width: 600px;">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span>
                </button>
                <h4 class="modal-title" id="myModalLabel3" style="font-size: 16px;">选择门店</h4>

            </div>
            <div class="modal-body">
                <div class="table-responsive">
                    <table class="table table-bordered">
                        <tr bgcolor="#eee">
                            <th></th>
                            <th>门店</th>

                        </tr>
                        <tbody id="templateHtml3">
                        <tr>
                            <td><input type="checkbox" name="merch" value="" data-mer="全部门店" id="whole"></td>

                            <td>全部门店</td>

                        </tr>
                        {volist name="machlist" id="vo"}

                        <tr>
                            <td><input type="checkbox" name="merch" value="{$vo.mid}" data-mer="{$vo.merchant}"></td>

                            <td>{$vo.merchant}</td>

                        </tr>
                        {/volist}
                        </tbody>
                    </table>
                </div>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                <button type="button" class="btn btn-primary" onclick="btn();">确定</button>

            </div>
        </div>
    </div>
</div>
<!-- Modal -->
<div class="modal fade" id="orderModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span>
                </button>
                <h4 class="modal-title" id="orderModalLabel" style="font-size: 16px;">退款列表</h4>
            </div>
            <div class="modal-body">
                <div class="table-responsive">
                    <table class="table table-bordered">
                        <thead>
                        <tr>
                            <th>订单号</th>
                            <th>退款金额</th>
                            <th>退款时间</th>
                            <th>操作</th>
                        </tr>
                        </thead>
                        <tbody id="orderlist">

                        </tbody>
                    </table>
                </div>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
            </div>
        </div>
    </div>
</div>
<!-- Modal -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span>
                </button>
                <h4 class="modal-title" id="myModalLabel" style="font-size: 16px;">订单详情</h4>
            </div>
            <div class="modal-body">
                <div class="table-responsive">
                    <table class="table table-bordered">
                        <tbody id="templateHtml"></tbody>
                    </table>
                </div>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
            </div>
        </div>
    </div>
</div>
<!-- 退款 详情Modal -->
<div class="modal fade" id="tkdetail" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span>
                </button>
                <h4 class="modal-title" id="tkdetailLabel" style="font-size: 16px;">退款详情</h4>
            </div>
            <div class="modal-body">
                <div class="table-responsive">
                    <table class="table table-bordered">
                        <tbody id="tkdetailHtml"></tbody>
                    </table>
                </div>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
            </div>
        </div>
    </div>
</div>

<script src="__STATIC_URL__/static/js/template.js"></script>

<script src="__STATIC_URL__/static/bootstrap-table/bootstrap-table.js"></script>
<script src="__STATIC_URL__/static/bootstrap-table/bootstrap-table-zh-CN.js"></script>
<script id="modallist" type="text/html">
    <tr>
        <td>商户订单号：</td>
        <td>{{list.orderid}}</td>
    </tr>
    <tr>
        <td>支付单号：</td>
        <td>{{list.orderno}}</td>
    </tr>
    <tr>
        <td>微信支付商户名称：</td>
        <td>{{list.machname}}</td>
    </tr>
    <tr>
        <td>交易时间：</td>
        <td>{{list.jtime}}</td>
    </tr>
    <tr>
        <td>交易状态：</td>
        <td>
            {{list.pay_statu}}
        </td>
    </tr>
    <tr>
        <td>收银设备</td>
        <td>
            {{list.d_cashier}}
        </td>
    </tr>
    <tr>
        <td>支付方式</td>
        <td>
            {{list.pay_fs}}
        </td>
    </tr>
    <tr>
        <td>应收金额：</td>
        <td>{{list.yf_price}}元</td>
    </tr>
    <tr>
        <td>折扣金额：</td>
        <td>{{list.zk_price}}元</td>
    </tr>
    <tr>
        <td>会员卡折扣：</td>
        <td>{{list.dis_card_zk}}元</td>
    </tr>
    <tr>
        <td>会员卡等级折扣：</td>
        <td>{{list.vip_card_zk}}元</td>
    </tr>
    <tr>
        <td>卡券抵扣：</td>
        <td>{{list.gel_card_zk}}元</td>
    </tr>
    <tr>
        <td>折扣卡券：</td>
        <td>{{list.hx_card_list}}</td>
    </tr>
    <tr>
        <td>实收金额：</td>
        <td>
            {{ if(list.pay_statu=="0") }} 0.00元{{/if}}
            {{ if(list.pay_statu!="0") }}{{list.price}}元{{/if}}
        </td>
    </tr>
    <!--<tr><td>退款金额：</td><td>{{ if(list.tk_status =="1") }} {{list.tk_price}} {{ /if }}</td></tr>-->
    <tr>
        <td>退款金额：</td>
        <td>{{list.tk_price}}元</td>
    </tr>
</script>
<!--退款模版-->
<script id="modaldetail" type="text/html">
    <tr>
        <td>商户名称：</td>
        <td>{{list.machname}}</td>
    </tr>
    <tr>
        <td>商户订单号：</td>
        <td>{{list.orderid}}</td>
    </tr>
    <tr>
        <td>退款单号：</td>
        <td>{{list.tk_orderid}}</td>
    </tr>
    <tr>
        <td>退款时间：</td>
        <td>{{list.addtime}}</td>
    </tr>
    <tr>
        <td>退款方式：</td>
        <td>
            {{list.tk_fs}}
        </td>
    </tr>
    <tr>
        <td>退款金额：</td>
        <td>￥{{list.refund_fee}}</td>
    </tr>
    <tr>
        <td>操作人/设备：</td>
        <td>{{list.action_user}}</td>
    </tr>
</script>
</body>
<script src="__STATIC_URL__/static/laydate/laydate.js"></script>
<script src="/wntable.js?v=1"></script>
<script>
    //下载报表
    function load() {

        $("#type").val("out_excel");

        $.ajax({
            url: "{:url('pay/paylog')}",
            data: $('#machform').serialize(),
            dataType: "json",
            async: false,
            type: "post",
            success: function (res) {
                window.location.href = res ;
            }
        })
    }
    $(function () {
        var type = "paylog";
        var url = "{:url('pay/paylog')}";
        getcolumn(type, url)

    });


    //搜索
    function searchforms() {
        $("#tablelist").bootstrapTable('refresh');
    }

</script>

<script>
    //执行一个laydate实例
    // var s=laydate.now();
    laydate.render({
        elem: '#search_date',
        type: 'datetime',
        range: true,
        change: function (value, date, date2, data3) {
            var s = value.split(" - ");
            var startdate = new Date(s[0]).getTime();
            var enddate = new Date(s[1]).getTime();
            var ldate = Math.floor((enddate - startdate) / (24 * 3600 * 1000));
            if (ldate > 30) {
                layer.alert("日期区间不能大于31天");
                $("#search_date").val("");
            }
        }
    });
</script>
<script>
    $("#whole").click(function () {
        selectAll();
    })

    function selectAll() {
        if ($("#whole").prop("checked")) {
            $("input[type='checkbox'][name='merch']").prop("checked", true);//全选
        } else {
            $("input[type='checkbox'][name='merch']").prop("checked", false);  //取消全选
        }
    }
</script>
<script>
    function btn() {
        $('#myModal3').modal('hide');

        var tempArray = new Array();
        var merarray = new Array();
        $("input:checkbox[name='merch']:checked").each(function (i) {

            tempArray[i] = $(this).val();
            merarray[i] = $(this).attr("data-mer");
        });
        var val = tempArray.join(',');
        $("#mach").val(val);
        $("#mac").val(merarray);
    }
</script>
<script type="text/javascript">
    $(function () {

        $("#myModal").on("show.bs.modal", function () {

            var id = $(event.target).data("id");
            var datas = {};
            $.ajax({
                url: "{:url('pay/getpayinfo')}",
                type: "post",
                async: true,
                data: {
                    orderid: id
                },
                success: function (data) {
                    datas.list = data;
                    var html = template('modallist', datas);
                    $("#templateHtml").html(html);
                }

            })
        });
        $("#myModal").on("show.bs.modal", function () {
            $("#templateHtml").html("");
        });
        $("#orderModal").on("show.bs.modal", function () {
            var id = $(event.target).attr("data-id");
            var td = "";
            $.ajax({
                url: "{:url('pay/gettklist')}",
                type: "post",
                async: true,
                data: {
                    orderid: id
                },
                success: function (data) {
                    if (data.length > 0) {
                        for (var i = 0; i < data.length; i++) {
                            td += "<tr><td>" + data[i].orderid + "</td><td>" + data[i].refund_fee + "</td><td>" + data[i].addtime + "</td><td><a class='btn-link' data-toggle='modal' data-target='#tkdetail'  data-id='" + data[i].id + "'>详情</a></td></tr>"
                        }
                        $("#orderlist").html(td);
                    } else {
                        $("#orderlist").html("<tr><td colspan='4' class='text-center'>暂无数据</td></tr>");
                    }

                }

            })
        });
//        退款详情
        $("#tkdetail").on("show.bs.modal", function () {
            var qx = "{:checkPath('pay/gettkinfo')}";
            if (qx == 0) {
                layer.alert("您没有权限访问");
                return false;
            }
            var id = $(event.target).attr("data-id");
            var datas = {};
            $.ajax({
                url: "{:url('pay/gettkinfo')}",
                type: "post",
                async: true,
                data: {
                    id: id
                },
                success: function (data) {
                    datas.list = data;
                    var html = template('modaldetail', datas);
                    $("#tkdetailHtml").html(html);
                }
            })
        });
        $("#tkdetail").on("hide.bs.modal", function () {
            $("#tkdetailHtml").html("");
        });
    });

</script>
</html>
